//
//  ImaginationTableViewCell.m
//  Gxj
//
//  Created by 💋索少杰 on 2017/9/15.
//  Copyright © 2017年 wkq. All rights reserved.
//

#import "ImaginationTableViewCell.h"

@implementation ImaginationTableViewCell


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        //添加到视图
        //用户点击头像响应
        //头像背景
        [self.contentView addSubview:self.viewIconCenterCX];
        [self.viewIconCenterCX addSubview:self.iconTouxiangCenterCX];
        //用户名字显示
        [self.contentView addSubview:self.nameTextCenterCX];
        //用户等级图标
        [self.contentView addSubview:self.dengjiTBCenterCX];
        //用户等级显示
        [self.contentView addSubview:self.dengjiTextCenterCX];
        //浏览人数图标
        [self.contentView addSubview:self.iconLiulangCenterCX];
        //观看人数
        [self.contentView addSubview:self.liulangNumCenterCX];
        //用户发表内容
        [self.contentView addSubview:self.contentTextCenterCX];
        //发表时间图标
        [self.contentView addSubview:self.iconShijianCenterCX];
        //用户发表时间
        [self.contentView addSubview:self.shijianTextCenterCX];
        //点赞数量
        [self.contentView addSubview:self.dianzanNumCenterCX];
        //点赞图片
        [self.contentView addSubview:self.dianzanIconCenterCX];
        //简介阴影
        [self.contentView addSubview:self.jianJieViewCenterCX];
        //简介内容
        [self.jianJieViewCenterCX addSubview:self.jianjieContextCenterCX];
        //用户发表图片
        [self.contentView addSubview:self.fabiaoImageCenterCX];
        //关注按钮
        [self.contentView addSubview:self.guanzhuCenterCX];
        //最佳讨论文字
        [self.contentView addSubview:self.zuijiaTextCenterCX];
        //最佳用户头像
        //        [self addSubview:self.iconZuijia];
        //线条
        [self.contentView addSubview:self.labelLine];
        
        //添加最佳用户头像
        //[self.iconZuijiaCenterBL addSubview:self.addButCenterBL];
        
        
        //商业标签
        for (int i = 0; i < 3; i++) {
            _theLabelCenterCX = [[UILabel alloc] initWithFrame:CGRectMake(kWidthScale(5) + kWidthScale(40) * i, kHeightScale(5), kWidthScale(35), kHeightScale(15))];
            
            _theLabelCenterCX.backgroundColor = [UIColor colorWithWhite:0 alpha:0.1];
            _theLabelCenterCX.text = @"商业";
            _theLabelCenterCX.textColor = [UIColor colorWithWhite:0.9 alpha:1];
            _theLabelCenterCX.font = [UIFont systemFontOfSize:kWidthScale(9)];
            _theLabelCenterCX.textAlignment = NSTextAlignmentCenter;
            _theLabelCenterCX.layer.cornerRadius = kWidthScale(5);
            _theLabelCenterCX.layer.masksToBounds = YES;
            
            [self.fabiaoImageCenterCX addSubview:self.theLabelCenterCX];
        }
        //最佳用户头像
        for (int i = 0; i < 5; i++) {
            _iconZuijia = [[UIImageView alloc] initWithFrame:CGRectMake(kWidthScale(84) * (i+1) - (66*i), kHeightScale(260), kWidthScale(20), kHeightScale(20))];
            
            _iconZuijia.image=[UIImage imageNamed:@"toixiang"];
            [self.contentView addSubview:_iconZuijia];
            
        }
        //适配方法
        [self setUpadapter];

        
    }
    return self;
}
- (void)setUpadapter
{
    //头像背景
    _viewIconCenterCX.sd_layout
    .topSpaceToView(self.contentView, kHeightScale(11))
    .leftSpaceToView(self.contentView, kWidthScale(15))
    .widthIs(kWidthScale(25))
    .heightIs(kHeightScale(25));
    
    //头像
    _iconTouxiangCenterCX.sd_layout
    .topSpaceToView(self.viewIconCenterCX, kHeightScale(1.5))
    .leftSpaceToView(self.viewIconCenterCX, kWidthScale(1.5))
    .widthIs(kWidthScale(22))
    .heightIs(kHeightScale(22));
    
    //名字
    _nameTextCenterCX.sd_layout
    .topSpaceToView(self.contentView, kHeightScale(10))
    .leftSpaceToView(self.viewIconCenterCX, kWidthScale(5))
    .widthIs(kWidthScale(100))
    .autoHeightRatio(0);
    
    //等级图标
    _dengjiTBCenterCX.sd_layout
    .topSpaceToView(self.nameTextCenterCX, kHeightScale(2))
    .leftSpaceToView(self.viewIconCenterCX, kWidthScale(5))
    .widthIs(kWidthScale(11))
    .heightIs(kHeightScale(11));
    //等级时间
    _dengjiTextCenterCX.sd_layout
    .topSpaceToView(self.nameTextCenterCX, kHeightScale(2))
    .leftSpaceToView(self.dengjiTBCenterCX, kWidthScale(2))
    .widthIs(kWidthScale(40))
    .autoHeightRatio(0);
    //发表内容
    _contentTextCenterCX.sd_layout
    .topSpaceToView(self.viewIconCenterCX, kHeightScale(5))
    .leftSpaceToView(self.contentView, kWidthScale(15))
    .rightSpaceToView(self.contentView, kWidthScale(15))
    .autoHeightRatio(0);
    
    //时间图标
    _iconShijianCenterCX.sd_layout
    .topSpaceToView(self.contentTextCenterCX, kHeightScale(5))
    .leftSpaceToView(self.contentView, kWidthScale(15))
    .widthIs(kWidthScale(15))
    .heightIs(kHeightScale(15));
    //时间
    _shijianTextCenterCX.sd_layout
    .topSpaceToView(self.contentTextCenterCX, kHeightScale(5))
    .leftSpaceToView(self.iconShijianCenterCX, kWidthScale(5))
    .widthIs(kWidthScale(30))
    .autoHeightRatio(0);
    //浏览图标
    _iconLiulangCenterCX.sd_layout
    .topSpaceToView(self.contentTextCenterCX, kHeightScale(7.5))
    .leftSpaceToView(self.shijianTextCenterCX, kWidthScale(5))
    .widthIs(kWidthScale(15))
    .heightIs(kHeightScale(10));
    //浏览人数
    _liulangNumCenterCX.sd_layout
    .topSpaceToView(self.contentTextCenterCX, kHeightScale(5))
    .leftSpaceToView(self.iconLiulangCenterCX, kWidthScale(5))
    .widthIs(kWidthScale(30))
    .autoHeightRatio(0);
    //点赞图片
    _dianzanIconCenterCX.sd_layout
    .topSpaceToView(self.contentTextCenterCX, kHeightScale(5))
    .leftSpaceToView(self.liulangNumCenterCX, kWidthScale(10))
    .widthIs(kWidthScale(13))
    .heightIs(kHeightScale(13));
    //点赞数量
    _dianzanNumCenterCX.sd_layout
    .topSpaceToView(self.contentTextCenterCX, kHeightScale(5))
    .leftSpaceToView(self.dianzanIconCenterCX, kWidthScale(5))
    .widthIs(kWidthScale(45))
    .autoHeightRatio(0);
    //简介View阴影
    _jianJieViewCenterCX.sd_layout
    .topSpaceToView(self.shijianTextCenterCX, kHeightScale(5))
    .leftSpaceToView(self.contentView, kWidthScale(15))
    .rightSpaceToView(self.contentView, kWidthScale(15))
    .heightIs(kHeightScale(49));
    //简介
    _jianjieContextCenterCX.sd_layout
    .topSpaceToView(self.jianJieViewCenterCX, 0)
    .leftSpaceToView(self.jianJieViewCenterCX, 0)
    .rightSpaceToView(self.jianJieViewCenterCX, 0)
    .heightIs(kHeightScale(49));
    //发表图片
    _fabiaoImageCenterCX.sd_layout
    .topSpaceToView(self.jianJieViewCenterCX, kHeightScale(10))
    .leftSpaceToView(self.contentView, kWidthScale(15))
    .rightSpaceToView(self.contentView, kWidthScale(15))
    .heightIs(kHeightScale(110));
    //最佳文字
    _zuijiaTextCenterCX.sd_layout
    .topSpaceToView(self.fabiaoImageCenterCX, kHeightScale(15))
    .leftSpaceToView(self.contentView, kWidthScale(15))
    .widthIs(kWidthScale(50))
    .autoHeightRatio(0);
    //线条
    _labelLine.sd_layout
    .bottomSpaceToView(self.contentView, 0)
    .leftSpaceToView(self.contentView, 0)
    .rightSpaceToView(self.contentView, 0)
    .heightIs(kHeightScale(1));

}
//头像背景
- (UIView *)viewIconCenterCX
{
    if (!_viewIconCenterCX)
    {
        _viewIconCenterCX=[[UIView alloc] init];
        _viewIconCenterCX.backgroundColor = [UIColor colorWithRed:(213.0/255) green:(213.0/255) blue:(213.0/255) alpha:1];;
        _viewIconCenterCX.layer.masksToBounds=YES;
        _viewIconCenterCX.layer.cornerRadius=12.5;
        _viewIconCenterCX.layer.shadowColor = [UIColor blackColor].CGColor;
        _viewIconCenterCX.layer.shadowOffset = CGSizeMake(-3, 1);
        _viewIconCenterCX.layer.shadowOpacity = 0.4;
        _viewIconCenterCX.layer.shadowRadius = 2.0;
        _viewIconCenterCX.clipsToBounds = NO;
    }
    return _viewIconCenterCX;
}
//头像
- (UIButton *)iconTouxiangCenterCX
{
    if (!_iconTouxiangCenterCX)
    {
        _iconTouxiangCenterCX=[[UIButton alloc] init];
        [_iconTouxiangCenterCX setBackgroundImage:[UIImage imageNamed:@"toixiang"] forState:UIControlStateNormal];
    }
    return _iconTouxiangCenterCX;
}
//名字
- (UILabel *)nameTextCenterCX
{
    if (!_nameTextCenterCX)
    {
        _nameTextCenterCX=[[UILabel alloc] init];
        _nameTextCenterCX.text=@"后悔的小公主";
        _nameTextCenterCX.textColor=[UIColor colorWithRed:(51.0/255) green:(51.0/255) blue:(51.0/255) alpha:1];
        _nameTextCenterCX.font=[UIFont systemFontOfSize:kWidthScale(12)];
    }
    return _nameTextCenterCX;
}
//等级图标
- (UIImageView *)dengjiTBCenterCX
{
    if (!_dengjiTBCenterCX)
    {
        _dengjiTBCenterCX=[[UIImageView alloc] init];
        _dengjiTBCenterCX.image=[UIImage imageNamed:@"dengji1"];
    }
    return _dengjiTBCenterCX;
}
//等级
- (UILabel *)dengjiTextCenterCX
{
    if (!_dengjiTextCenterCX)
    {
        _dengjiTextCenterCX=[[UILabel alloc] init];
        _dengjiTextCenterCX.text=@"100级";
        _dengjiTextCenterCX.textColor=[UIColor colorWithRed:(153.0/255) green:(153.0/255) blue:(153.0/255) alpha:1];
        _dengjiTextCenterCX.font=[UIFont systemFontOfSize:kWidthScale(10)];
    }
    return _dengjiTextCenterCX;
}
//用户发表动态
- (UILabel *)contentTextCenterCX
{
    if (!_contentTextCenterCX)
    {
        _contentTextCenterCX=[[UILabel alloc] init];
        _contentTextCenterCX.text=@"什么时候觉得，数据分析真的非常有用？";
        _contentTextCenterCX.textColor=[UIColor colorWithHexString:@"#666666"];
        _contentTextCenterCX.font=[UIFont systemFontOfSize:kWidthScale(14)];
    }
    return _contentTextCenterCX;
}
//发表时间图标
- (UIImageView *)iconShijianCenterCX
{
    if (!_iconShijianCenterCX)
    {
        _iconShijianCenterCX=[[UIImageView alloc] init];
        _iconShijianCenterCX.image=[UIImage imageNamed:@"time"];
    }
    return _iconShijianCenterCX;
}
//发表时间
- (UILabel *)shijianTextCenterCX
{
    if (!_shijianTextCenterCX)
    {
        _shijianTextCenterCX=[[UILabel alloc] init];
        _shijianTextCenterCX.text=@"5:20";
        _shijianTextCenterCX.textColor=[UIColor colorWithRed:(153.0/255) green:(153.0/255) blue:(153.0/255) alpha:1];
        _shijianTextCenterCX.font=[UIFont systemFontOfSize:kWidthScale(12)];
    }
    return _shijianTextCenterCX;
}
//浏览图标
- (UIImageView *)iconLiulangCenterCX
{
    if (!_iconLiulangCenterCX)
    {
        _iconLiulangCenterCX=[[UIImageView alloc] init];
        _iconLiulangCenterCX.image=[UIImage imageNamed:@"liulans"];
    }
    return _iconLiulangCenterCX;
}
//浏览人数
- (UILabel *)liulangNumCenterCX
{
    if (!_liulangNumCenterCX)
    {
        _liulangNumCenterCX=[[UILabel alloc] init];
        _liulangNumCenterCX.text=@"1000";
        _liulangNumCenterCX.textColor=[UIColor colorWithRed:(153.0/255) green:(153.0/255) blue:(153.0/255) alpha:1];
        _liulangNumCenterCX.font=[UIFont systemFontOfSize:kWidthScale(12)];
    }
    return _liulangNumCenterCX;
}
//点赞图片
- (UIImageView *)dianzanIconCenterCX
{
    if (!_dianzanIconCenterCX)
    {
        _dianzanIconCenterCX=[[UIImageView alloc] init];
        _dianzanIconCenterCX.image=[UIImage imageNamed:@"zans"];
    }
    return _dianzanIconCenterCX;
}
//点赞数量
- (UILabel *)dianzanNumCenterCX
{
    if (!_dianzanNumCenterCX)
    {
        _dianzanNumCenterCX=[[UILabel alloc] init];
        _dianzanNumCenterCX.text=@"100000";
        _dianzanNumCenterCX.textColor=[UIColor colorWithRed:(153.0/255) green:(153.0/255) blue:(153.0/255) alpha:1];
        _dianzanNumCenterCX.font=[UIFont systemFontOfSize:kWidthScale(12)];
    }
    return _dianzanNumCenterCX;
}
//背景颜色
- (UIView *)jianJieViewCenterCX
{
    if (!_jianJieViewCenterCX)
    {
        _jianJieViewCenterCX = [[UIView alloc] init];
        _jianJieViewCenterCX.layer.shadowColor = [UIColor blackColor].CGColor;
        _jianJieViewCenterCX.layer.shadowOffset = CGSizeMake(0, 1);
        _jianJieViewCenterCX.layer.shadowOpacity = 0.2;
        //        _shadowView.layer.shadowRadius = 6.0;
        //        _shadowView.layer.cornerRadius = 6.0;
        _jianJieViewCenterCX.clipsToBounds = NO;
    }
    return _jianJieViewCenterCX;
}
//简介内容
- (KQlable *)jianjieContextCenterCX
{
    if (!_jianjieContextCenterCX)
    {
        _jianjieContextCenterCX = [[KQlable alloc] init];
        _jianjieContextCenterCX.text = @"风暴简介：个环境可凉快和包教包零零落落零零落落零零落落零零落落零零落落啦啦啦\n";
        _jianjieContextCenterCX.backgroundColor = [UIColor colorWithRed:251.0/255 green:251.0/255 blue:251.0/255 alpha:1];
        _jianjieContextCenterCX.textColor = [UIColor colorWithHexString:@"#999999"];
        _jianjieContextCenterCX.font=[UIFont systemFontOfSize:kWidthScale(11)];
        _jianjieContextCenterCX.layer.cornerRadius = kWidthScale(10);
        _jianjieContextCenterCX.layer.masksToBounds = YES;
        _jianjieContextCenterCX.numberOfLines=0;
        NSDictionary *attrDict1 = @{ NSForegroundColorAttributeName: [UIColor colorWithHexString:@"#666666"] };
        NSString *str = @"风暴简介：";
        _jianjieContextCenterCX.attributedText = [[NSAttributedString alloc] initWithString: str attributes: attrDict1];
        
    }
    return _jianjieContextCenterCX;
}
- (void)drawTextInRect:(CGRect)rect {
    UIEdgeInsets insets = {0, 5, 0, 5};
    [self drawTextInRect:UIEdgeInsetsInsetRect(rect, insets)];
}

//发表图片
- (UIImageView *)fabiaoImageCenterCX
{
    if (!_fabiaoImageCenterCX)
    {
        _fabiaoImageCenterCX=[[UIImageView alloc] init];
        _fabiaoImageCenterCX.image=[UIImage imageNamed:@"banner"];
        _fabiaoImageCenterCX.layer.masksToBounds=YES;
        _fabiaoImageCenterCX.layer.cornerRadius=kWidthScale(10);
    }
    return _fabiaoImageCenterCX;
}
//最佳讨论
- (UILabel *)zuijiaTextCenterCX
{
    if (!_zuijiaTextCenterCX)
    {
        _zuijiaTextCenterCX=[[UILabel alloc] init];
        _zuijiaTextCenterCX.text=@"最佳讨论";
        _zuijiaTextCenterCX.textColor=[UIColor colorWithHexString:@"#666666"];
        _zuijiaTextCenterCX.font=[UIFont systemFontOfSize:kWidthScale(12)];
    }
    return _zuijiaTextCenterCX;
}

//添加最佳讨论人头像
- (UIButton *)addButCenterCX
{
    if (!_addButCenterCX)
    {
        _addButCenterCX=[[UIButton alloc] init];
        [_addButCenterCX setBackgroundImage:[UIImage imageNamed:@"jias"] forState:UIControlStateNormal];
    }
    return _addButCenterCX;
}
//线条
- (UILabel *)labelLine
{
    if (!_labelLine)
    {
        _labelLine=[[UILabel alloc] init];
        _labelLine.backgroundColor=[UIColor colorWithRed:242.0/255.0 green:242.0/255.0 blue:242.0/255.0 alpha:1];
    }
    return _labelLine;
}

@end
